<template>
	<view class="back-view">
		<view class="view-background"></view>
		<view class="white-view-back">
			<view class="top-back">
				<view class="top-name">用户留言</view>
				<view class="close-back" @click="closeBtnAction">
					<image class="close-img" src="../../../static/close.png"></image>
				</view>
			</view>
			<view class="top-line"></view>
			<scroll-view class="center-back" scroll-y="true">
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">姓名</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{detailItem.userName}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">联系电话</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{detailItem.userMobile}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">留言内容</view>
						<view class="item-name-des">:</view>
					</view>
					<text class="item-content">
						{{detailItem.content}}
					</text>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">反馈时间</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{detailItem.createTime}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">回复内容</view>
						<view class="item-name-des">:</view>
					</view>
					<text class="item-content">{{detailItem.reply}}</text>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">备注</view>
						<view class="item-name-des">:</view>
					</view>
					<text class="item-content">{{detailItem.remark}}</text>
				</view>
			</scroll-view>
			<view class="bottom-back">
				<view class="bottom-btn bottom-btn-cancel" @click="clickReplayAction" v-if="showType == 'reply'">回复
				</view>
				<view class="bottom-btn" v-if="showType != 'detail'" @click="clickRemarkAction">{{remarkTitle}}</view>
				<view class="bottom-btn" v-if="showType == 'detail'" @click="closeBtnAction">返回</view>
			</view>
		</view>
		<messageReplay v-if="showReplay" :replayItem="detailItem" v-on:successBack='updataRequest()'
			@messageReplayClose='clickMessageReplayClose'>
		</messageReplay>
		<messageRemark v-if="showRemark" :remarkItem="detailItem" v-on:successBack='updataRequest()'
			@messageRemarkClose='clickMessageRemarkClose'></messageRemark>
	</view>
</template>

<script>
	import messageReplay from "@/packageB/PC/basicManage/userMessageReplay.vue"
	import messageRemark from "@/packageB/PC/basicManage/userMessageRemark.vue"
	export default {

		components: {
			messageReplay,
			messageRemark
		},
		props: {
			showType: {
				type: String,
				default: 'reply', //reply：回复，remark:备注
			},
			item: {
				type: Object,
				default: {},
			},
		},

		data() {
			return {
				showReplay: false,
				showRemark: false,
				detailItem: {},
				remarkTitle:'添加备注'
			}
		},
		onLoad() {

		},
		mounted() {
			this.detailItem = this.item;
			this.requestData()
		},
		methods: {
			//网络请求
			async requestData() {
				let _this = this
				const res = await this.$myRequest({
					url: '/admin/leaveMsg/' + this.item.id,
					method: 'GET',
				})
				console.log('返回结果', res)
				if (res.data.code == 200) {

					_this.detailItem = res.data.data
					if(_this.detailItem.remark){
						_this.remarkTitle = '编辑备注'
					}
				}
			},
			updataRequest() {
				this.requestData()
				this.$emit("successBack");
			},
			closeBtnAction() {
				this.$emit('messageDetailClose')
			},

			clickReplayAction() {
				this.showReplay = true;
			},
			clickMessageReplayClose() {
				this.showReplay = false;
			},
			clickRemarkAction() {
				this.showRemark = true;
			},
			clickMessageRemarkClose() {
				this.showRemark = false;
			},
		},
	}
</script>

<style>
	.back-view {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 9999;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.view-background {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: -1;
		background-color: rgba(0, 0, 0, 0.3);
	}

	.white-view-back {
		width: 60%;
		padding: 24px;
		max-height: 80%;
		background-color: white;
		margin-top: -70px;
		border-radius: 4px;
	}

	.top-back {
		display: flex;
		justify-content: space-between;
	}

	.top-name {
		font-size: 18px;
		font-weight: normal;
		color: #333333;

	}

	.close-back {
		cursor: pointer;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.close-img {
		width: 12px;
		height: 12px;
	}

	.top-line {
		height: 1px;
		background: #EEEEEE;
		width: 100%;
		margin-top: 20px;
		margin-bottom: 20px;
	}

	.item-back {
		display: flex;
		align-items: flex-start;
		margin-bottom: 10px;
	}


	.item-name {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		width: 60px;
		min-width: 60px;
		text-align: justify;
		text-align-last: justify;
		display: inline-block;
	}

	.item-name-des {

		font-size: 14px;
		font-weight: 400;
		color: #999999;
		margin-right: 16px;
	}

	.item-file-name {
		font-size: 12px;
		font-weight: 400;
		color: #333333;
	}

	.item-content {
		font-size: 14px;
		font-weight: 400;
		color: #333333;
	}

	.item-img {
		width: 24px;
		height: 24px;
		min-width: 24px;
		margin-right: 8px;
	}

	.bottom-back {
		margin-top: 30px;
		width: 100%;
		min-height: 30px;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.bottom-btn {
		cursor: pointer;
		width: 104px;
		height: 32px;
		background: #2DA9C5;
		border-radius: 2px;
		color: #FFFFFF;
		font-size: 14px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.bottom-btn-cancel {
		cursor: pointer;
		margin-right: 10px;
		background: #FFFFFF;
		border: 1px solid #EEEEEE;
		color: #333333;
	}

	.center-back {
		width: 100%;
		max-height: 384px;
		height: 384px;
	}
</style>
